<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Animated seach box</title>
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
    />
    <style>
      * {
        box-sizing: border-box;
      }
      body {
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0px;
        padding: 0px;
        width: 100vw;
        height: 100vh;
        background-color: black;
      }
      .search-box {
        width: fit-content;
        height: fit-content;
        position: relative;
      }
      .input-search {
        height: 50px;
        width: 50px;
        border-style: none;
        padding: 10px;
        font-size: 18px;
        outline: none;
        border-radius: 25px;
        transition: all 0.5s ease-in-out;
        background-color: #8b8b8b;
        padding-right: 40px;
        color: #fff;
      }
      .input-search::placeholder {
        color: #8b8b8b;
        font-size: 18px;
      }
      .btn-search {
        width: 50px;
        height: 50px;
        border-style: none;
        font-size: 20px;
        font-weight: bold;
        outline: none;
        cursor: pointer;
        border-radius: 50%;
        position: absolute;
        right: 0px;
        color: #ffffff;
        background-color: unset;
      }
      .btn-search:focus ~ .input-search {
        width: 300px;
        border-radius: 0px;
        background-color: unset;
        border-bottom: 1px solid rgba(255, 255, 255, 0.5);
        transition: all 500ms cubic-bezier(0, 0.11, 0.35, 2);
      }
      .input-search:focus {
        width: 300px;
        border-radius: 0px;
        background-color: unset;
        border-bottom: 1px solid rgba(255, 255, 255, 0.5);
        transition: all 500ms cubic-bezier(0, 0.11, 0.35, 2);
      }
    </style>
  </head>
  <body>
    <div class="search-box">
      <button class="btn-search"><i class="fas fa-search"></i></button>
      <input type="text" class="input-search" placeholder="Type to search..." />
    </div>
  </body>
</html>
